<template>
	<view class="page-boxsf">
		<view class="user-infos" hover-class="hover_class" @click="jump('userInfo')">
			<view>
				<image :src="userInfo.portrait ? userInfo.portrait : '../../static/image/user_icon.png'"></image>
				<view>
					<view>{{ userInfo.nickname || '请登录' }}</view>
					<view>{{ userInfo.mobile }}</view>
				</view>
			</view>
			<image src="../../static/image/moresd.png"></image>
		</view>
		<view class="order-box">
			<view class="tit-row">
				<text>我的订单</text>
				<view hover-class="hover_class" @click="getOrder('')">
					<text>查看全部订单</text>
					<image src="../../static/image/moresd.png"></image>
				</view>
			</view>
			<view class="order-action">
				<view hover-class="hover_class" @click="getOrder(1)">
					<image src="../../static/image/version/fukuan.png"></image>
					<view>待付款</view>
				</view>
				<view hover-class="hover_class" @click="getOrder(3)">
					<image src="../../static/image/version/shouhuo.png"></image>
					<view>待收货</view>
				</view>
				<view hover-class="hover_class" @click="getOrder(4)">
					<image src="../../static/image/version/yishou.png"></image>
					<view>已收货</view>
				</view>
				<view hover-class="hover_class" @click="getOrder('')">
					<image src="../../static/image/version/shouhou.png"></image>
					<view>售后</view>
				</view>
			</view>
		</view>
		<view class="card-row">
			<view hover-class="hover_class" @click="jump('myCollection')">
				<image src="../../static/image/version/coll.png"></image>
				<view>
					<text>我的收藏</text>
					<view>
						<image src="../../static/image/moresd.png"></image>
					</view>
				</view>
			</view>
			<view hover-class="hover_class" @click="jump('addressMan')">
				<image src="../../static/image/version/address.png"></image>
				<view>
					<text>地址管理</text>
					<view>
						<image src="../../static/image/moresd.png"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="card-row">
			<view hover-class="hover_class" @click="callPhone">
				<image src="../../static/image/version/fuwu.png"></image>
				<view>
					<text>服务中心</text>
					<view>
						<text>{{ userInfo.contactTelephone || '' }}</text>
						<image src="../../static/image/moresd.png"></image>
					</view>
				</view>
			</view>
			<view>
				<image src="../../static/image/version/fukuan.png"></image>
				<view>
					<text>推荐码</text>
					<view>
						<text>{{ userInfo.id || '' }}</text>
					</view>
				</view>
			</view>
			<view hover-class="hover_class" @click="jump('userInfo')">
				<image src="../../static/image/version/set.png"></image>
				<view>
					<text>系统设置</text>
					<view>
						<image src="../../static/image/moresd.png"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		userIndex
	} from 'utils/api/user.js'
	export default {
		data() {
			return {
				userInfo: {}
			}
		},
		onLoad() {
			uni.showShareMenu({
				withShareTicket:true,
				menus:["shareAppMessage","shareTimeline"]
			})
		},
		//分享到朋友圈
		onShareTimeline(res) {
		    return {
		        title: '顺晟新物流',
		        type: 0,
		        summary: "",
		    }
		},
		onShow() {
			this.getData()
		},
		methods: {
			jump(route) {
				uni.setStorageSync('htmlData', this.userInfo.advert.content)
				uni.navigateTo({
					url: `/userPackage/pages/${route}/index?title=操作说明`
				})
			},
			getOrder(status) {
				uni.navigateTo({
					url: `/userPackage/pages/order/index?status=${status}`
				})
			},
			// 电话
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.userInfo.contactTelephone,
					success: function() {
						console.log('拨打电话成功');
					},
					fail: function() {
						console.log('拨打电话失败');
					}
				});
			},
			getData() {
				userIndex().then((res) => {
					this.userInfo = res.data
				})
			}
		}
	}
</script>

<style scoped lang="scss">
@import "static/css/my.scss";
</style>